package com.jzo2o.customer.controller.inner;

import com.jzo2o.api.customer.AddressBookApi;
import com.jzo2o.api.customer.dto.response.AddressBookResDTO;
import com.jzo2o.common.utils.BeanUtils;
import com.jzo2o.customer.model.domain.AddressBook;
import com.jzo2o.customer.service.IAddressBookService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping
@Slf4j
public class InnerAddressBookController implements AddressBookApi {

    @Autowired
    private IAddressBookService addressBookService;

    @Override
    @GetMapping("/inner/address-book/{id}")
    public AddressBookResDTO getAddressById(@PathVariable Long id) {
        log.info("查询地址详情：{}", id);
        AddressBook byId = addressBookService.getById(id);
        return BeanUtils.toBean(byId, AddressBookResDTO.class);

    }


}
